﻿package states {
	import external.*;
	import org.flixel.*;
	import states.*;
	import levels.*;

	/**
	 * ...
	 * @author test
	 */
	public class LoadState extends FlxState {
		public var tmx:TMX;
		public var begin:Boolean;
		public var start_level_id:String;

		override public function update():void {
			super.update();

			if (begin){
				if (FlxG.save == FlxG.levels.length){
					trace("trans");
					FlxG.save = 0;
					FlxG.state = FlxG.levels[start_level_id]._state;
				}
			}
		}

		public function LoadState(){
			super();

			start_level_id = "level2";
			FlxG.score = 0;
			begin = new Boolean(false);
			
			
			set_levels();
		}

		public function set_levels():void {
			FlxG.levels = new Array();

			insert_level("level0");
			insert_level("level1");
			insert_level("level2");

			begin = true;
		}

		public function insert_level(id:String):void {
			FlxG.levels.push(id);
			FlxG.levels[id] = new Level(id, id + ".tmx");
		}

	}

}